package com.situ.mall.web.controller;


import com.situ.mall.common.entity.Relation;
import com.situ.mall.common.mapper.RelationMapper;
import com.situ.mall.common.service.IRelationService;
import com.situ.mall.common.util.StringUtil;
import com.situ.mall.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author JavaWizard
 * @since 2024-02-22
 */
@RestController
@RequestMapping("/client")
public class RelationController {

    @Autowired
    private IRelationService relationService;

    @Autowired
    private RelationMapper relationMapper;

    //添加就诊人
    @PostMapping("/relation/add")
    public ResultVO add (Relation relation) {
        StringUtil.checkTel(relation.getTel());
        relationMapper.insert(relation);
        return ResultVO.data(200, "请求成功", relationMapper.selectByMemberId(relation.getMemberId()));
    }

    //查询所有就诊人
    @GetMapping("/relation/getRelations")
    public ResultVO getRelations(Integer memberId) {
        return ResultVO.data(200, "请求成功", relationMapper.selectByMemberId(memberId));
    }

}
